package cn.webrx;

import java.util.Random;

public class RandDemo {
    public static void main(String[] args) {
        Random rand = new Random();
        //
        System.out.println(rand.nextInt());//随机整数

        //0-4
        System.out.println(rand.nextInt(5));

        //System.out.println(rand.nextInt(101));//0-100

        //1-100
        System.out.println(rand.nextInt(100)+1);

        //随机0-1 随机double
        System.out.println(Math.random());

        //0 - 1
        //long num = Math.round(Math.random()*1); //0-1
        //long num = Math.round(Math.random()*5); //0-5
        long num = Math.round(Math.random()*6) + 1; //1-7
        System.out.println(num);


    }
}
